﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace TagBasedResourceManagePlatform.UI.Wpf.UIComponents
{
    /// <summary>
    /// ResourceListViewItem.xaml 的交互逻辑
    /// </summary>
    public partial class ResourceListViewItem : UserControl
    {

        #region Properties

        public Database.Resource RelatedResource
        {
            get { return _relatedResource; }
        }

        #endregion



        #region Fields

        #region UI Components
        private Popup _uiDetailPanel;
        private Border _uiLoader;
        private TextBlock _uiTitle;
        private TextBlock _uiFullTitle;
        private TextBlock _uiMineType;
        private TextBlock _uiTags;
        #endregion

        private Database.Resource _relatedResource;

        #endregion


        public ResourceListViewItem() :
            this(null)
        {}

        public ResourceListViewItem(Database.Resource resource)
        {
            InitializeComponent();

            this.Loaded += ResourceListViewItem_Loaded;
            this.MouseLeave += ResourceListViewItem_MouseLeave;
        }

        #region Private Functions

        private void PrivateDisplayInfomation()
        {
            if (_relatedResource == null) return;

            
        }

        #endregion

        #region Event Handlers

        private void ResourceListViewItem_MouseLeave(object sender, MouseEventArgs e)
        {
            _uiDetailPanel.IsOpen = false;
        }

        private void ResourceListViewItem_Loaded(object sender, RoutedEventArgs e)
        {
            _uiDetailPanel =(Popup) this.Template.FindName("Part_Detail", this);
        }

        private void UserControl_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (e.ChangedButton == MouseButton.Left)
            {
                _uiDetailPanel.IsOpen = true;
                e.Handled = true;
            }
        }

        #endregion

        #region Private Functions



        #endregion

    }
}
